from random import random
from math import sqrt
from time import process_time

DARTS = 120000
hists = 0
start=process_time()
for i in range(1, DARTS):
    x, y = random(), random()
    dict = sqrt(x ** 2 + y ** 2)
    if dict <= 1.0:
        hists = hists + 1
pi = 4 * (hists / DARTS)
print('PI的值是%s' % pi)
print("运行时间：{0}s".format(process_time()-start))
